﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DoctorUserManage.aspx.cs" Inherits="RegisterWeb.Manager.SystemUserManager.ManageDoctorUser" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link href="../../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../../js/jquery-easyui-1.2.6/themes/gray/easyui.css" rel="stylesheet"
        type="text/css" />
    <link href="../../js/jquery-easyui-1.2.6/themes/icon.css" rel="stylesheet" type="text/css" />
    <script src="../../js/jquery-easyui-1.2.6/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../js/jquery-easyui-1.2.6/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>


<script type="text/javascript">

    var url; //提交数据的路径
    var formId; //当天要提交的Form的编号
    var dialogId; //对话框的编号

    var successCallback = function (result) {
        //alert(result);
        //result为请求处理后的返回值
        var result = eval('(' + result + ')');
        if (result.success) {
            $.messager.show({
                title: 'Success',
                msg: result.msg
            });
            $(dialogId).dialog('close');
            $('#dg').datagrid('reload');
        } else {
            $.messager.show({
                title: 'Error',
                msg: result.msg
            });
        }
    }

   $(function () {
        //预加载编辑框
        $("#editDoctorUser").dialog({
            modal: true,
            "title": "编辑用户信息",
            width: 400,
            height: 300,
            href: 'EditDoctorUser.aspx'
        });
        $("#editDoctorUser").dialog('open').dialog('close');

        $('#dg').datagrid({

            onDblClickRow: function (rowIndex, rowData) {
                $('#editDoctorUser').dialog('open');
                $("#DoctorUser_UserName").val(rowData.DoctorUser_UserName);
                $("#DoctorUser_Password").val(rowData.DoctorUser_Password);
                $("#DoctorUser_RePassword").val(rowData.DoctorUser_Password);
                url = 'ashx/DoctorUserHandler.ashx?action=edit&id=' + rowData.DoctorUser_ID;
                formId = "#editDoctorUs";
                dialogId = "#editDoctorUser";

            }
        });

    });
    //编辑医生用户部分
    function editDoctorUser() {
        var row = $('#dg').datagrid('getSelected');
        if (row) {
            $('#editDoctorUser').dialog('open');
            // $('#edit').form('clear');
            $("#DoctorUser_UserName").val(row.DoctorUser_UserName);
            $("#DoctorUser_Password").val(row.DoctorUser_Password);
            $("#DoctorUser_RePassword").val(row.DoctorUser_Password);
            url = 'ashx/DoctorUserHandler.ashx?action=edit&id=' + row.DoctorUser_ID;
            formId = "#editDoctorUs";
            dialogId = "#editDoctorUser";

        }
        else {
            $.messager.alert("提示", "您没有选中任何行！");
        }
    }
    
    
    function saveInfo() {
        $(formId).form('submit', {
            url: url,
            onSubmit: function () {
                return $(this).form('validate');
            },
            success: successCallback
        });
    }

    //  删除医院部分
   function deleteDoctor() {
        var row = $('#dg').datagrid('getSelected');
        if (row) {
            $.messager.confirm('删除提示', '确定要删除' + row.DoctorUser_UserName + '吗', function (r) {
                if (r) {
                    $.post('ashx/DoctorUserHandler.ashx', { id: row.DoctorUser_ID, action: 'delete' }, function (data, status) {
                        if (data == "ok") {
                            $('#dg').datagrid('reload');
                            $.messager.show({
                                title: 'Success',
                                msg: '删除成功!'
                            });
                        } else {
                            $.messager.show({
                                title: 'Error',
                                msg: '删除失败!'
                            });
                        }
                    });
                }
            });
        }
    }
    //验证医生用户昵称
   function check() {
       var value = $("#DoctorUser_UserName").val();
        if (value != "") {
            $.post('ashx/DoctorUserHandler.ashx?action=check', { action: 'check', name: value }, function (data, status) {
                if (data == 'ok') {
                    $("#DoctorUser_UserName").val("");
                    $("#error").text("用户名" + value + "已存在！");
                }
                else {
                    $("#error").text("");
                }
            });
        }
    }

    //验证密码是否相同
    function checkPwd() {
        var DoctorUser_RePassword = $("#DoctorUser_RePassword").val();
        var DoctorUser_Password = $("#DoctorUser_Password").val();
        if (DoctorUser_RePassword!= DoctorUser_Password) {
            $("#error1").text("两次密码不一致");
            $("#DoctorUser_RePassword").val("");
        }
        else {
            $("#error1").text("");
        }

    } 
</script>

</head>
<body>
    <form id="form1" >
    <div region="center" title="医院用户信息管理" >
<table id="dg" title="医院用户信息管理" class="easyui-datagrid" style="overflow:auto ; height:550px"
			url="ashx/DoctorUserHandler.ashx?action=get"
			toolbar="#toolbar" pagination="true"
			rownumbers="true" fitColumns="true" singleSelect="true" 
            pageSize="20"
            >
		<thead>
			<tr>
			<th field="Doctor_ID" width="50">

医生姓名</th>
				<th field="DoctorUser_UserName" width="50">用户昵称</th>
				<th field="DoctorUser_Password"  hidden="true"

width="50">用户密码</th>
		
                <th field="DoctorUser_AddTime" width="50" >添加时间时间</th>
                 <th field="DoctorUser_Recoder" width="50">记录者:</th>
              
                 <th idField="DoctorUser_ID" width="10"  hidden="true" >医生用户ID</th>
                 
			</tr>
		</thead>
	</table>

    <div id="toolbar" style="padding:5px;height:auto">
                    <a href="#" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editDoctorUser()">编辑医生用户</a>
                    <a href="#" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="deleteDoctor()">删除医生用户</a>

    </div>


			<div id="addDoctorUser" class="easyui-dialog" closed="true" buttons="#addDoctorUser-buttons" style="padding:10px 20px">
        	</div>
			<div id="addDoctorUser-buttons">
				<a href="#" class="easyui-linkbutton" iconCls="icon-ok" onclick="saveInfo()">保存</a>
				<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick='$("#addDoctorUser").dialog("close");'>关闭</a>
			</div>

            <div id="editDoctorUser" class="easyui-dialog" closed="true" buttons="#editDoctorUser-buttons" style="padding:10px 20px">
        	</div>
            <div id="editDoctorUser-buttons">
				<a href="#" class="easyui-linkbutton" iconCls="icon-ok"  onclick="saveInfo()">保存</a>
				<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick='$("#editDoctorUser").dialog("close");'>关闭</a>
			</div>

    </div>
    </form>
</body>
</html>
